#include <bits/stdc++.h>
using namespace std;
#define br endl
#define pr cout
#define in cin
#define v vector<int>
#define m1 map<int, int>
#define vs vector<string>
#define p pair<int, int>
#define f(n) for (int i = 1; i <= n; i++)
#define f1(n) for (int j = 0; j < n; j++)
#define lli long long int
#define ld long double
#define pb push_back
#define vpi vector<pair<int, int>>
#define vms vector<map<string, int>>
#define vmi vector<map<int, int>>
void solve()
{
int n, positive, negative=0;
cin>>n;
vector<int> vec(n);
vector<int>maximum(n);
int ans[n];
int i=0;
for(auto x: vec)
{
cin>>x;
maximum[i]=x;
i++;
}
// maximum
sort(maximum.begin(),maximum.end() );
reverse(maximum.begin(), maximum.end());
int x=0;
for(int i=0; i<n ; i++)
{
if(maximum[i]>=0)
{
ans[i]=++x;
}
if(maximum[i]<0)
{
for(int j=0; j<i; j++)
{
if(maximum[j]==-1*maximum[i])
{
ans[i]=--x;
}
else
ans[i]= x;
}
}
}
for(int i=0 ; i<n ; i++)
{
pr<<ans[i]<<" ";
}
pr<<br;
// minimum
for(int i=0; i<n; i++)
{
if(maximum[i]>=0)
{
for(int j= i+1; j<n; j++)
{
if(maximum[i]== -1 * maximum[j])
{
negative++;
}
}
}
}
positive=1;
int z=0;
while(z<n){
cout<<positive<<" ";
z++;
if(negative>0)
{
cout<<0<<" ";
--positive;
negative--;
z++;
}
positive++;
}
pr<<br;
}
int main()
{
int t;
in >> t;
bool x = true;
if (x == true)
while (t--)
solve();
else
solve();
}
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |